﻿@using Halower.JqGirdToolKit
@using Halower.JqGrid.Core
@using Halower.JqGrid.Enum
@model MVC5Demo.Controllers.ViewDto
@{
    ViewBag.Title = "Home Page";
    var g = Html.GridToolKit();
}
<script>
    function customerFmatter(cellvalue, options, rowObject) {
        var html = [];
        html.push("<input value='测试按钮" + rowObject[0] + "' class=\"btn btn-default btn-small\" onclick='alert(\"测试按钮" + rowObject[0] + "\")' type='button'>");
        return html.join();
    }
</script>
@*@(Html.JqGrid("testJqGrid", new GridConfiguration
    (
                ColumnFactory.Create("Id", "编号").SetWidth(300).SetEditable(ColumnEditType.Text),
                ColumnFactory.Create("Name", "姓名").SetWidth(300).SetEditable(ColumnEditType.Textarea),
                ColumnFactory.Create("Skin", "肤色").SetWidth(300),
                ColumnFactory.Create(null, "操作").SetWidth(100).SetFormatter("customerFmatter")
     )
    )

    .GroupHeaders(new GroupHeader("Name", 2, "<font style=\"color:red;\">详细内容</font>"))
    .Caption("JqGrid测试").Height("250")
    .Url("/Home/GridData", new Dictionary<string, string> { { "name", "halower" } })
    .SortName("Name").SortOrder(SortOrderType.Desc).LoadText("正在加载数据请骚等...")
    .BuiltInOperation(GridOperatorType.Add | GridOperatorType.Edit | GridOperatorType.Delete)
    .Pager("pageId").RowList(new[] { 5, 15, 33 })
    .SubGrid(
                     ColumnFactory.Create("Name", "姓名").SetWidth(150),
                     ColumnFactory.Create("Language", "中文").SetWidth(150),
                     ColumnFactory.Create("Country", "国籍").SetWidth(150)
                )
             .SubGridUrl("/Home/SubGridData").SubGridPostParams(new[] { "Name" }))*@

@(g.JqGrid("testJqGrid", g.Param(x => x.Name)).MainGrid(
    g.GridColumn(x => x.Id, 300).Searchable(CellTypes.Number),
    g.GridColumn(x => x.Name, 300),
    g.GridColumn(x => x.Skin, 300).Sortable().Searchable(),
    g.GridColumn("操作", null, "customerFmatter"))
        .Caption("JqGrid测试").Height("250")
    .Url("/Home/GridData", new Dictionary<string, string> { { "name", "halower" } })
        .SortName(g.Param(x => x.Name)).SortOrder().LoadText("正在加载数据请骚等...")
        .Pager("pageId").GroupHeaders(g.HeaderStruct(x => x.Name, 2, "<font style=\"color:red;\">详细内容</font>"))
    .SubGrid(
        g.GridColumn(x => x.Name, 300),
        g.GridColumn(x => x.Language, 300),
        g.GridColumn(x => x.Country, 300)
    ).MultiSearch()
    .BuiltInOperation(GridOperators.Search).Multiselect()
    .SubGridUrl("/Home/SubGridData").SubGridPostParams(g.Param(x => x.Name)))

